#!/usr/bin/python

reader = open('purposes_tolower_singular', 'r')
writer = open('purpose.suffix', 'w')
s = []
out = []
while True:
    line = reader.readline()
    if line == "":
        break
    line = line[0:-1]
    line = ' ' + line + ' '
    line = line.replace(' a ', ' ')
    line = line.replace(' an ', ' ')
    line = line.replace(' one ', ' ')
    if (line.find('a ') == 0):
        line = line[2:]
    if (line.find('an ') == 0):
        line = line[3:]
    if (line.find('one ') == 0):
        line = line[4:]
    line = line.strip()
    items = line.split()
    flag = True
    outline = ''
    for i in items:
        if flag:
            outline = i
            flag = False
            continue
        outline = i + " " + outline
    s.append(outline)
s.sort()
for i in s:
    flag = True
    outline = ''
    items = i.split()
    for j in items:
        if flag:
            outline = j
            flag = False
            continue
        outline = j + " " + outline
    out.append(outline)
for i in out:
    writer.write(i + "\n")
reader.close()
writer.close()
